#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "defs.h"
#include "cpu.h"
#include "rv32.h"
#include "err.h"

int
rv32fd_tell (int inst) {
    DEF_I_INST (FLW, 0x2, 0x7, {});
    DEF_S_INST (FSW, 0x2, 0x27, {});
    DEF_I_INST (FLD, 0x3, 0x7, {});
    DEF_S_INST (FSD, 0x3, 0x27, {});
    DEF_R4_INST (FMADD_S, 0x0, 0x43, {});
    DEF_R4_INST (FMSUB_S, 0x0, 0x47, {});
    DEF_R4_INST (FNMSUB_S, 0x0, 0x4B, {});
    DEF_R4_INST (FNMADD_S, 0x0, 0x4F, {});
    DEF_R_SP_INST (FADD_S, 0x0, 0x53, {});
    DEF_R_SP_INST (FSUB_S, 0x4, 0x53, {});
    DEF_R_SP_INST (FMUL_S, 0x8, 0x53, {});
    DEF_R_SP_INST (FDIV_S, 0xC, 0x53, {});
    DEF_R2_INST (FSQRT_S, 0x2C, 0x0, 0x53, {});
    DEF_R_INST (FSGNJ_S, 0x10, 0x0, 0x53, {});
    DEF_R_INST (FSGNJN_S, 0x10, 0x1, 0x53, {});
    DEF_R_INST (FSGNJX_S, 0x10, 0x2, 0x53, {});
    DEF_R_INST (FMIN_S, 0x14, 0x0, 0x53, {});
    DEF_R_INST (FMAX_S, 0x14, 0x1, 0x53, {});
    DEF_R2_INST (FCVT_W_S, 0x60, 0x0, 0x53, {});
    DEF_R2_INST (FCVT_WU_S, 0x60, 0x1, 0x53, {});
    DEF_R2_INST (FMV_X_W, 0x70, 0x0, 0x53, {});
    DEF_R_INST (FEQ_S, 0x50, 0x2, 0x53, {});
    DEF_R_INST (FLT_S, 0x50, 0x1, 0x53, {});
    DEF_R_INST (FLE_S, 0x50, 0x0, 0x53, {});
    DEF_R2_INST (FCLASS_S, 0x70, 0x0, 0x53, {});
    DEF_R2_INST (FCVT_S_W, 0x68, 0x0, 0x53, {});
    DEF_R2_INST (FCVT_S_WU, 0x68, 0x1, 0x53, {});
    DEF_R2_INST (FMV_W_X, 0x78, 0x0, 0x53, {});
    DEF_R4_INST (FMADD_D, 0x1, 0x43, {});
    DEF_R4_INST (FMSUB_D, 0x1, 0x47, {});
    DEF_R4_INST (FNMSUB_D, 0x1, 0x4B, {});
    DEF_R4_INST (FNMADD_D, 0x1, 0x4F, {});
    DEF_R_SP_INST (FADD_D, 0x1, 0x53, {});
    DEF_R_SP_INST (FSUB_D, 0x5, 0x53, {});
    DEF_R_SP_INST (FMUL_D, 0x9, 0x53, {});
    DEF_R_SP_INST (FDIV_D, 0xD, 0x53, {});
    DEF_R2_INST (FSQRT_D, 0x2D, 0x0, 0x53, {});
    DEF_R_INST (FSGNJ_D, 0x11, 0x0, 0x53, {});
    DEF_R_INST (FSGNJN_D, 0x11, 0x1, 0x53, {});
    DEF_R_INST (FSGNJX_D, 0x11, 0x2, 0x53, {});
    DEF_R_INST (FMIN_D, 0x15, 0x0, 0x53, {});
    DEF_R_INST (FMAX_D, 0x15, 0x1, 0x53, {});
    DEF_R2_INST (FCVT_S_D, 0x20, 0x1, 0x53, {});
    DEF_R2_INST (FCVT_D_S, 0x21, 0x0, 0x53, {});
    DEF_R_INST (FEQ_D, 0x51, 0x2, 0x53, {});
    DEF_R_INST (FLT_D, 0x51, 0x1, 0x53, {});
    DEF_R_INST (FLE_D, 0x51, 0x0, 0x53, {});
    DEF_R2_INST (FCLASS_D, 0x71, 0x0, 0x53, {});
    DEF_R2_INST (FCVT_W_D, 0x61, 0x0, 0x53, {});
    DEF_R2_INST (FCVT_WU_D, 0x61, 0x1, 0x53, {});
    DEF_R2_INST (FCVT_D_W, 0x69, 0x0, 0x53, {});
    DEF_R2_INST (FCVT_D_WU, 0x69, 0x1, 0x53, {});
    printf ("Not a rv32fd inst. Forwarding to next ISA ...\n");
    return -1;
    executed:
    return 0;
}

int
rv32f_exec () {

}